<?php
/**
 * @ClassName: Equipment
 * @Description: TODO
 * @author: ynbjykj
 * @Date: 2025-11-26 10:38
 * @Version: V1.0.0
 */

namespace app\api\controller\filters;

use app\api\controller\Api;
use app\common\enum\RackEnum;

use app\common\model;

class Equipment extends Api
{
    function getSelectData()
    {
        $deviceStatusList = [];
        $deviceTypeList = [];
        $deviceModelList = [];
        $holderTypeList = [];
        $adPositionList = [];
        $salesMethodList = [];

        //设备状态
        foreach (RackEnum::statusText(true) as $k => $item) {
            $deviceStatusList[] = [
                'value' => $k,
                'label' => $item,
                'text' => $item,
            ];
        }

        //设备类型
        $deviceTypeList = model\EquipmentType::where('is_show', 1)->field('id as value, name as label, name as text')->select();

        //设备型号
        foreach (RackEnum::rackTypes(true) as $k => $item) {
            $deviceModelList[] = [
                'value' => $k,
                'label' => $item,
                'text' => $item,
            ];
        }

        //设备来源
        foreach (model\Equipment::$holder_types as $k => $item) {
            $holderTypeList[] = [
                'value' => $k,
                'label' => $item,
                'text' => $item,
            ];
        }

        //广告位置
        foreach (RackEnum::putAdPosition(true) as $k => $item) {
            $adPositionList[] = [
                'value' => $k,
                'label' => $item,
                'text' => $item,
            ];
        }

        //销售方式
        foreach (model\Equipment::$sales_methods as $k => $item) {
            $salesMethodList[] = [
                'value' => $k,
                'label' => $item,
                'text' => $item,
            ];
        }

        $result = [
            'deviceStatusList' => $deviceStatusList,
            'deviceTypeList' => $deviceTypeList,
            'deviceModelList' => $deviceModelList,
            'holderTypeList' => $holderTypeList,
            'adPositionList' => $adPositionList,
            'salesMethodList' => $salesMethodList,
        ];

        return json(["code" => 1, "msg" => "获取成功", "data" => $result]);
    }

}